<?xml version="1.0" encoding="UTF-8"?>
<!--
To change this template, choose Tools | Templates
and open the template in the editor.
-->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<ui:composition xmlns="http://www.w3.org/1999/xhtml"
                xmlns:p="http://primefaces.prime.com.tr/ui"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:c="http://java.sun.com/jsp/jstl/core"
                template="./../templates/StakeholderPortalTemplate.xhtml">
    <h:head>
        <title>Advertising Management</title>
    </h:head>
    <ui:define name="content">
        <h:form>
            <f:view beforePhase="#{viewAdvertisementManagedBean.initView}">

                <p:panel header="Advertisement Units" >
                    <p:messages id="statusMessages" redisplay="false" />
                    <h:panelGrid columns="1" cellpadding="5" >

                        <h:column> 
                            <p:commandButton id ="btnAdd" actionListener="#{viewAdvertisementManagedBean.redirectPage}" 
                                             value ="#{bundle['btnAdd.advertisement']}" style="float:right;"/>      

                            <p:commandButton id="analysis" value="#{bundle['advertisement.analystic']}" style="float:right;" />
                        </h:column>
                        <h:outputText id="resultList" value="Total Promotion Created: &nbsp; #{viewAdvertisementManagedBean.adsList.size()}" 
                                      style="font-size: 10px; color: red; float: left;"/>

                        <p:dataTable id="adListTable" var="advertisement" style="width: 780px;" 
                                     rendered="true" value="#{viewAdvertisementManagedBean.adsList}">

                            <p:column>  
                                <f:facet name="header">  
                                    #{bundle['header.bannerThumbnail']}
                                </f:facet>  

                                <p:graphicImage value="#{advertisement.promotionImageUrl}" style="width:130px; height: 75px;" />

                            </p:column> 


                            <p:column style="width: 25%">  
                                <f:facet name="header" >  
                                    #{bundle['ad.title']}
                                </f:facet>  
                                <h:outputText value="#{advertisement.adName}" /> 

                            </p:column> 

                            <p:column style="width: 15%">  
                                <f:facet name="header">  
                                    #{bundle['dates']}
                                </f:facet>  
                                <h:outputText value="#{advertisement.startDate}">  
                                    <f:convertDateTime dateStyle="medium" type="date" timeZone="UTC+8"/>
                                </h:outputText>
                                <br/>
                                <center>
                                    <h:outputLabel id="pEndDatelabel" value ="-" style="font-weight: bold;" />
                                    <br/></center>
                                <h:outputText value="#{advertisement.endDate}">
                                    <f:convertDateTime dateStyle="medium" type="date" timeZone="UTC+8" />
                                </h:outputText> 

                            </p:column> 


                            <p:column>
                                <f:facet name="header">
                                    Keywords tagging
                                </f:facet>


                                <ui:repeat id="activityList" value="#{advertisement.activityType}" var="newsItem"> 
                                    <li>
                                        <h:outputText value="#{newsItem.activityCategory}" style="font-size: smaller;" converter="activityTypeConverter"/>
                                    </li>
                                </ui:repeat>

                                <ui:repeat id="cuisineType" value="#{advertisement.cuisineTypeList}" var="cuisine"> 
                                    <li>
                                        <h:outputText value="#{cuisine.cusine}" style="font-size: smaller;" converter="cuisineTypeConverter"/>
                                    </li>     
                                </ui:repeat>

                                <ui:repeat id="foodplace" value="#{advertisement.fnBTypeList}" var="suitable"> 
                                    <li>
                                        <h:outputText value="#{suitable.suitableFor}" style="font-size: smaller;" converter="fnbTypeConverter"/>
                                    </li>

                                </ui:repeat>

                            </p:column>





                            <p:column>  
                                <f:facet name="header">  
                                    #{bundle['header.option']}
                                </f:facet>  
                                <p:commandButton id="btnEdit" image="ui-icon ui-icon-pencil"
                                                 actionListener="#{viewAdvertisementManagedBean.view_Edit_Branch(advertisement)}" 
                                                 title="#{bundle['managemedia.remove.button']}" />
                                <p:commandButton image="ui-icon ui-icon-trash" title="Delete" onclick="confirmation.show()" type="button"/>  

                                <p:confirmDialog message="Are you sure about to delete the advertisement?"  
                                                 showEffect="bounce" hideEffect="explode"  
                                                 header="Initiating delete process" severity="alert" widgetVar="confirmation">  

                                    <p:commandButton value="Yes Sure" update="statusMessages, adListTable" oncomplete="confirmation.hide()"  
                                                     actionListener="#{viewAdvertisementManagedBean.view_Delete_Branch(advertisement)}">
                                        <f:ajax render="adListTable"/>
                                    </p:commandButton>  
                                    <p:commandButton value="Not Yet" onclick="confirmation.hide()" type="button" />   

                                </p:confirmDialog>  
                            </p:column> 





                        </p:dataTable>    


                    </h:panelGrid>



                </p:panel>


            </f:view>
        </h:form>
    </ui:define>
</ui:composition>
